using System;
using System.Collections.Generic;
using System.Drawing;
using System.Diagnostics;

namespace Nate.Pathfinding
{
    [DebuggerDisplay("Index = {Index}")]
    public class Node
    {
        // 
        // Public Properties
        //

        public NUtils.AutoSortList<double, Node> Neighbors
        {
            get
            {
                return _neighbors;
            }

        }
        public List<Edge> Edges
        {
            get
            {
                return _edges;
            }

        }
        public Point Point
        {
            get
            {
                return _point;
            }
        }
        public int X
        {
            get
            {
                return _point.X;
            }
        }
        public int Y
        {
            get
            {
                return _point.Y;
            }
        }
        public bool Visited
        {
            get
            {
                return _visited;
            }
            set
            {
                _visited = value;
            }
        }
        public int Index
        {
            get
            {
                return _index;
            }
        }
        public uint ColorArgb
        {
            get
            {
                return _color_argb;
            }
        }

        public double DistanceSquared(Node other)
        {
            return (X - other.X) * (X - other.X) + (Y - other.Y) * (Y - other.Y);
        }

        public double Distance(Node other)
        {
            return System.Math.Sqrt(DistanceSquared(other));
        }
        public double DistanceManhattan(Node other)
        {
            return Math.Abs(X - other.X) + Math.Abs(Y - other.Y);
        }

        //
        // Private Data
        //

        public Node(int x, int y, int index, uint color_argb)
        {
            _color_argb = color_argb;
            _index = index;
            _visited = false;
            _point = new Point(x, y);
            _neighbors = new NUtils.AutoSortList<double, Node>();
            _edges = new List<Edge>();
        }

        int         _index;             // Index to the graph that this node lives in.
        Point       _point;
        List<Edge>  _edges;
        bool        _visited;
        uint        _color_argb;
        NUtils.AutoSortList<double, Node> _neighbors;
    }
}
